<template>
	<view>
		
		<view class="banner" v-for="(value, key) in surveyList" :key="key" @click="goDetail(value)">
			
			<view class="img-title">
				<view class="">
					<view>{{ value.formName }}</view>
					<view class="fabiao">{{value.createTime}}</view>
				</view>
				
			</view>
			<!-- <view class="img-Detail">
				{{value.foodsDetail}}
			</view> -->
		</view>
		<u-loadmore :status="status" />
		<!-- <graceLoading :loadingType="loadingType"/> -->
	</view>
</template>

<script>
	import easyLoadimage from '../components/easy-loadimage/easy-loadimage.vue';
	import {
		pageInformation
	} from '@/api/survey.js';
	export default {
		name: 'news',
		data() {
			return {
				banner: {},
				pageMore: true,
				loadingType: 0,
				graceFullLoading: true,
				params: {
					pageNum: 1,
					pageSize: 10,
					status:2
				},
				pageMore: true,
				surveyList: [],
				status: 'loadmore',
				footstypelist: [],
				imglist: [],
				scrollTop: 0
			};
		},
		onPageScroll({
			scrollTop
		}) {
			// 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
			this.scrollTop = scrollTop;
		},
		components: {
			easyLoadimage
		},
		onReachBottom: function() {
			this.loadMoreFunc();
		},
		
		onLoad() {
			this.initParams();
			this.getFoods();
		},

		methods: {
			goBack(){
				uni.navigateBack()
			},
			add() {
				console.log('添加')
				uni.navigateTo({
					url: 'publish'
				});
			},
			//页面返回初始化数据
			initParams() {
				this.surveyList = [];
				// this.loadingType = 4;
				this.params.pageNum = 1;
				this.pageMore = true;
			},
			goDetail(e) {
					uni.navigateTo({
						url: 'detail?key='+e.formKey
					});
			},
			getFoods() {
				pageInformation(this.params).then(
					res => {
						this.pathRes(res.data);
					},
					err => {
						this.$api.showTip('查询错误');
						this.loadingType = 0;
					}
				);
			},
			pathRes(data) {
				uni.showLoading({
					title: '正在加载...',
					mask: true
				});
				if (data.code == 0) {
					uni.hideLoading();

					if (data.data.list.length == 0) {
						// this.loadingType = 3;
						this.status = 'nomore';
						console.log('显示数据', this.status);
						return;
					}
					if (data.data.isLastPage) {
						this.pageMore = false;
						this.surveyList = this.surveyList.concat(data.data.list);
						// this.loadingType = 2;
						this.status = 'nomore';
					} else {
						if (data.data.isFirstPage) {
							this.surveyList = data.data.list;
						} else {
							this.surveyList = this.surveyList.concat(data.data.list);
							console.log('不是第一页', this.surveyList);
						}
						this.params.pageNum++;
						// this.loadingType = 0;
					}
					
				} else {
					this.$api.showTip(res.data.msg);
				}
			},
			formattime(time) {
				// let ttDate = time;
				let ttDate = time.replace(/(\d{4}).(\d{1,2}).(\d{1,2})/gm, '$1年$2月$3日');
				return ttDate;
			},
			
			loadMoreFunc: function() {
				if (!this.pageMore) {
					return;
				}
				this.getFoods(this.params);
			},
			swiperchange: function(e) {
				console.log(e);
			},
			btnClick() {
				uni.navigateTo({
					url: 'foodMenuAdd'
				});
			},
			goback() {
				uni.navigateBack();
			}
		}
	};
</script>

<style scoped lang="less">
	/deep/.u-nav-slot{
		display: flex;
	}
	/deep/.uicon-plus{
		margin-left: 90rpx;
	}
	.banner {
		overflow: hidden;
		position: relative;
		background-color: #ffffff;
		margin: 20rpx 15rpx;
		padding: 20rpx;
		box-sizing: border-box;
		border-radius: 5rpx;
	}
	
	.grace-padding-p {
		padding: 30rpx;
	}

	.img-radius-hw {
		border-radius: 14rpx;
		background-position: center center;
		width: 100%;
		height: 350rpx;
	}

	.img-title {
		font-size: 30rpx;
		font-weight: bold;
		color: #333333;
		opacity: 1;
	}

	.fabiao {
		margin-top: 10px;
		color: #999;
		font-weight: 400;
	}

	.grace-title {
		padding: 0 !important;
		line-height: 2em;
	}

	.img-Detail {
		font-pageNum: 28rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
		opacity: 1;
	}

	
</style>